// 简易工厂主要有三个角色
// 工厂（Factory）: 负责创建所以对象实例
// 抽象对象（AbstractProduct）: 负责描述所有实例公共接口
// 真实对象（ConcreteProduct）: 具体对象

package creational

import (
	"fmt"
)

type SimpleFactory struct{}

func (f *SimpleFactory) CreateProduct(name string) SimpleAbstract {
	var abstract SimpleAbstract

	switch name {
	case "SimpleImplementOne":
		abstract = SimpleImplementOne{}
	case "SimpleImplementTwo":
		abstract = SimpleImplementTwo{}
	default:
		panic("this is not SimpleAbstract")
	}

	return abstract
}

type SimpleAbstract interface {
	Method()
}

type SimpleImplementOne struct{}

func (SimpleImplementOne) Method() {
	fmt.Println("SimpleImplementOne")
}

type SimpleImplementTwo struct{}

func (SimpleImplementTwo) Method() {
	fmt.Println("SimpleImplementTwo")
}
